package heven.holt.wan.android.binding

import android.view.View
import android.widget.TextView
import androidx.databinding.BindingAdapter
import heven.holt.library.binding.fromHtml
import heven.holt.wan.android.model.Tag

@BindingAdapter("android:bingTag")
fun bindTag(textView: TextView, tag: List<Tag>?) {
    textView.visibility = if (tag.isNullOrEmpty()) View.GONE else View.VISIBLE
    if (!tag.isNullOrEmpty()) {
        textView.text = tag.first().name
    }
}

@BindingAdapter("android:super_chapter_name", "android:chapter_name")
fun formatChapterName(textView: TextView, superChapterName: String?, chapterName: String?) {
    fromHtml(textView, "$superChapterName·$chapterName")
}